﻿<%@ Page Language="C#" MasterPageFile="~/Admin/AdminMaster.Master" AutoEventWireup="true" CodeFile="FileManger.aspx.cs" Inherits="PeachLite.Admin.FileManger" %>

<asp:Content ID="c1" runat="server" ClientIDMode="Static" ContentPlaceHolderID="cphHead">
    <link type="text/css" rel="Stylesheet" href="resx/fimanger.css" />
    <script type="text/javascript" src="js/ajaxfileupload.js"></script>
    <script type="text/javascript" src="js/fimanger.js"></script>
    <script type="text/javascript" >
        function del(e) {
            var path = $(e).parents("dt").attr("p") ? $(e).parents("dt").attr("p") : "";
            if (path == "") {
                return;
            }
            if (!confirm('确定要删除"' + path + '"吗？')) {
                return;
            }

            $.ajax({
                url: "x/ajax.ashx",
                data: { p: path, c: AJAXCODE.CheckFolder, r: Math.random() },
                type: "POST",
                dataType: "json",
                success: function (data) {
                    if (!data.Success) {
                        if (data.Message != null && data.Message != "") {
                            alert(data.Message);
                        }
                        return;
                    }
                    if (data.Message != null && data.Message != "") {
                        if (!confirm(data.Message)) {
                            return;
                        }
                    }
                    fx({ p: path, c: AJAXCODE.DeleteFile, r: Math.random() }, function (data) {
                        if (data.Success) {
                            $(e).parents("li").remove();
                        }
                    });
                }
            });
        }

        function newfolder() {
            var name = $("#tbname").val() ? $("#tbname").val() : "";
            var path = $("#curPath").text() ? $("#curPath").text() : "";
            if (name == "") {
                alert("请填写文件夹名称！");
                return;
            }
            if (path == "") {
                alert("文件路径有误！");
                return;
            }
            fx({ name: name, path: path, c: AJAXCODE.NewFolder, r: Math.random }, function (data) {
                if (data.Success) {
                    if (data.O.fpath) {
                        $("#fiList").append(data.O.fpath);
                    }
                }
            });
        }

        function addFile() {
            var path = $("#curPath").text() ? $("#curPath").text() : "";
            if (path == "") {
                alert("文件路径有误！");
                return
            }
            FileManger.open({
                skin: 'blue',
                mode: 1,
                saveMode: 1,
                multiple: true,
                maxCount: 5,
                savePath: path,
                back: function (o) {
                    if (o) {
                        for (var i = 0; i < o.OS.length; i++) {
                            var html = "<li><dl><dt p='" + o.OS[i].Url + "'><a title='" + o.OS[i].Name + "'><img src='" + o.OS[i].Icon + "' alt='" + o.OS[i].Name + "' /></a><span class='del' onclick='del(this);'>×</span></dt><dd>" + o.OS[i].Name + "</dd></dl></li>";
                            $("#fiList").append(html);
                        }
                    }
                }
            });
        }
    </script>
</asp:Content>


<asp:Content ID="c2" runat="server" ClientIDMode="Static" ContentPlaceHolderID="cphMain">
    <div class="box box1">
        <div class="hd">
            <div class="tit">
                <i class="iconfont">&#xf07b;</i> <span>文件管理</span>
            </div>
        </div>
        <div class="bd filelist">
            <div class="fitp clearfix">
                <div class="pnav">当前位置：<span class="cur" id="curPath"><asp:Literal ID="filePath" runat="server" ClientIDMode="Static"></asp:Literal></span><a href='filemanger.aspx?p=<asp:Literal ID="backPath" runat="server" ClientIDMode="Static"></asp:Literal>' class="back">返回上一级目录</a></div>
                <div class="op">
                    <a class="btn btn3" onclick="addFile();">上传文件</a>
                    <a class="btn btn2" onclick="newfolder();">新建</a>
                    <input type="text" class="txt" id="tbname"/>
                    <span class="t">新建文件夹：</span>
                </div>
            </div>
            <ul class="filt ft96 clearfix" id="fiList">
                <asp:Literal ID="fileList" runat="server" ClientIDMode="Static"></asp:Literal>
            </ul>
        </div>
    </div>
</asp:Content>
